<?php
class RadUtils {
	public static function generateRadTicketName($enumRadType, $requesTime) {
        $localizedTypeName  =   Utils::getEnumTextByKey(EnumerationConstant::PARACLINIC_TYPE, $enumRadType);
        $time   =   explode(' ', $requesTime);
        $name   =   $localizedTypeName . " " . $time[0];

        return $name;
    }

    public static function getAssignmentListKeyValue($assignmentList, $showStatus = false) {
        $ret    =   array();
    	foreach ($assignmentList as $item){
            $ret[$item['rad_ticket_id']] =   RadUtils::generateRadTicketName($item['enum_rad_type'], $item['request_time']);
            if ($showStatus) {
                $status =   Utils::getEnumTextByKey(EnumerationConstant::RAD_TICKET_STATUS, $item['enum_ticket_status']);
                $ret[$item['rad_ticket_id']]    .=  " [$status]";
            }
        }

        return $ret;
    }

    public static function convertToTicketItemType($enumRadType) {
    	switch ($enumRadType) {
    		case Utils::getEnumKey(EnumerationConstant::PARACLINIC_TYPE, EnumerationConstant::PARACLINIC_XRAY):
    			return TicketItem::XRAY_TYPE;
            case Utils::getEnumKey(EnumerationConstant::PARACLINIC_TYPE, EnumerationConstant::PARACLINIC_ENDO):
                return TicketItem::ENDO_TYPE;
            case Utils::getEnumKey(EnumerationConstant::PARACLINIC_TYPE, EnumerationConstant::PARACLINIC_ULTRA):
                return TicketItem::ULTRA_TYPE;
            default:
                return '';
    	}
    }

    /**
     * Get path of the module relative to app root.
     * @example "modules/dept_rad
     * @return string Relative path
     */
    public static function getModulePath() {
        $config     =   Celini::configInstance();
    	$modulePath =   $config->get('module_paths');
        $fullPath   =   $modulePath['dept_rad'] . "/";
        $appRoot    =   APP_ROOT;
        return str_replace($appRoot, "", $fullPath);
    }

    public static function generateRadItemName($serviceName, $done, $showStatus = true) {
        if ($done) {
            $status =   L10nHelper::_("Done");
        }
        else {
            $status =   L10nHelper::_("No result");
        }
        $itemName  =   $serviceName;
        if ($showStatus) {
        	$itemName  .=  " [$status]";
        }

        return $itemName;
    }
}
?>